home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_224 / xebec / parx.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  3KB  |  82 lines

  1. /* The idea here is to write a replacement for the cumbersome Xebec Park
  2. program.  This is a tiny convenient program which will park the heads of your
  3. Xebec hard disk.  At first I made it so that if you have more than one disk
  4. on your scsi controller, it would attempt to park all of them, but then I made
  5. it simply assume that it should park unit 0.  Later I might add command line /
  6. tool type selection of which to park.  By Paul Kienitz 2/89, public domain.
  7.  
  8. Thanks to Matt Dillon for TDebug, which showed me what request the Xebec
  9. scsi.device task considers to mean "park" (after I went through about 47
  10. modified versions of TDebug to find all the necessary data, and ended up
  11. disassembling Xebec's Park anyway).  The Park program puts some pretty weird
  12. shit in the io_Unit field of the IO request.
  13. */
  14.  
  15. #include <exec/io.h>
  16. #include <devices/trackdisk.h>
  17. #include <libraries/dos.h>
  18. #include <functions.h>
  19. #include <Paul.h>
  20.  
  21. #define Unit 0L
  22.  
  23. long _main()     /* use of _main instead of main is Aztec-ism */
  24. {
  25.     struct IOExtTD q;
  26. #   define qr q.iotd_Req
  27. #   define qrm qr.io_Message
  28. #   define qrmn qrm.mn_Node
  29.     register str *lp;
  30.     register struct Process *me = (adr) FindTask(null);
  31.     char foo[600];
  32.     str Unitstruct[6];
  33.     short fooset;
  34.     adr mess = null, port = null;
  35.     long hair = 0;
  36.  
  37.     setmem(&q, sizeof(struct IOExtTD), 0);
  38.     setmem(foo, 600, 0);
  39.     if (!me->pr_CLI) {
  40.     WaitPort(&me->pr_MsgPort);
  41.     mess = GetMsg(&me->pr_MsgPort);
  42.     }
  43.     if (port = CreatePort(null, 0L)) {
  44.     qrmn.ln_Pri = 0;
  45.     qrm.mn_ReplyPort = port;
  46.     if (!OpenDevice("scsi.device", Unit, &q, 0L)) {
  47.         qrmn.ln_Type = NT_MESSAGE;
  48.         qrm.mn_Length = 48;
  49.         qr.io_Command = TD_RAWREAD;
  50.         qr.io_Length = 0;
  51.         qr.io_Offset = 0;
  52.         qr.io_Data = 0;
  53.         qr.io_Flags = 0;
  54.         lp = Unitstruct;
  55.         qr.io_Unit = (adr) lp;
  56.         fooset = ((long) foo & 1) != 0;
  57.         lp[1] = foo + 10 + fooset;
  58.         lp[2] = lp[1] - 1;     /* this doesn't mean anything */
  59.         lp[3] = lp[1] - 2;     /*   to me, who knows why to do this? */
  60.         lp[0] = lp[3] + 512;   /* who knows if 512 is necessary? */
  61.         lp[0][0] = 17;         /* THIS IS ESSENTIAL */
  62.         lp[1][0] = 0;          /* i don't know */
  63.         lp[2][0] = 0;
  64.         lp[3][0] = 0;
  65.         lp[4] = Unit;
  66.         lp[5] = 0;
  67.         if (DoIO(&q))
  68.         hair = ERROR_SEEK_ERROR;  /* closest approximation */
  69.         CloseDevice(&q);
  70.     } else hair = ERROR_DEVICE_NOT_MOUNTED;  /* sort of the right idea */
  71.     } else hair = ERROR_NO_FREE_STORE;   /* almost certainly correct */
  72.     if (port) DeletePort(port);
  73.     if (mess) {
  74.     Forbid();
  75.     ReplyMsg(mess);
  76.     }
  77.     me->pr_Result2 = hair;
  78.     return (hair == 0 ? 0L : 10L);
  79.     /* Well, heck.  I don't know how to tell the Workbench to beep the screen
  80.     and record the "Last Error". */
  81. }
  82.